//
//  SQCodeTableViewCell.m
//  energy
//
//  Created by 周曼迪 on 2021/7/13.
//

#import "SQCodeTableViewCell.h"

#import "SQCodeModel.h"
#import "SQSpecialDetailsModel.h"



@implementation SQCodeTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    [self.lab_danger SQCornerRadius:10];
}

+(CGFloat)cellHeight:(BaseModel *)model{
    return W(88);
}

-(void)setModel:(BaseModel<BaseCellModelProtocol> *)model{
    self.lab_leve.hidden = YES;
    self.lab_leveText.hidden = YES;
    if ([model isKindOfClass:SQCodeModelRiskPoint.class]) {
        SQCodeModelRiskPoint * riskPointModel = model;
        self.lab_leve.hidden = NO;
        self.lab_leveText.hidden = NO;
        self.lab_content.text = riskPointModel.rp_name;
        /**rp_lec_level=1，低风险。
         rp_lec_level=2，一般风险。
         rp_lec_level=3，较大风险。
         rp_lec_level=4，重大风险*/
        if ([riskPointModel.rp_lec_level isEqualToString:@"1"]) {
            self.lab_leve.text = @"低风险";
        }else if ([riskPointModel.rp_lec_level isEqualToString:@"2"]){
            self.lab_leve.text = @"一般风险";
        }else if ([riskPointModel.rp_lec_level isEqualToString:@"3"]){
            self.lab_leve.text = @"较大风险";
        }else if ([riskPointModel.rp_lec_level isEqualToString:@"4"]){
            self.lab_leve.text = @"重大风险";
        }
        
    //    if ([riskPointModel.type isEqualToString:@"1"]) {
            if ([riskPointModel.rp_count isEqualToString:@"0"]) {
                self.btn_report.hidden = NO;
                self.lab_danger.backgroundColor = [UIColor colorNamed:@"577eb0Color"];
                
            }else if ([riskPointModel.rp_count isEqualToString:@"1"]) {
                self.btn_report.hidden = YES;
                self.lab_danger.backgroundColor = [UIColor colorNamed:@"999Color"];
            }
    }else if ([model isKindOfClass:SQSpecialDetailsModelContent.class]){
        SQSpecialDetailsModelContent * dataModel = model;
        
        self.lab_content.text = dataModel.ic_name;
        self.lab_leve.hidden = YES;
        self.lab_leveText.hidden = YES;
        
        
    //    if ([riskPointModel.type isEqualToString:@"1"]) {
            if ([dataModel.sq_type isEqualToString:@"0"]) {
                self.btn_report.hidden = NO;
                self.lab_danger.backgroundColor = [UIColor colorNamed:@"577eb0Color"];
                
            }else if ([dataModel.sq_type isEqualToString:@"1"]) {
                self.btn_report.hidden = YES;
                self.lab_danger.backgroundColor = [UIColor colorNamed:@"999Color"];
            }
    }
    
    

}

/**上报*/
- (IBAction)clickReport:(UIButton *)sender {
    self.cellTitle((int)self.indexPath.section, (int)self.indexPath.row);
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
